package com.tk.array;
//打印数组、排序
import java.util.Arrays;

public class Demo04 {
    public static void main(String[] args) {
        int[] a = {1, 2, 45, 78, 23, 25};
        System.out.println(a); //[I@1b6d3586

        System.out.println(Arrays.toString(a));

        printArrays(a);
        System.out.println();

        Arrays.sort(a); //数组排序
        System.out.println(Arrays.toString(a));
    }

    public static void printArrays(int[] a) {
        for (int i = 0; i < a.length; i++) {
            if (i == 0) {
                System.out.print("[");
            }
            if (i == a.length - 1) {
                System.out.print(a[i] + "]");
            } else {
                System.out.print(a[i] + ", ");
            }
        }
    }
}
